package com.googlecode.perfectable.prosperable.webchat.message;

import org.codehaus.jackson.annotate.JsonCreator;
import org.codehaus.jackson.annotate.JsonProperty;

import com.googlecode.perfectable.prosperable.message.ClientMessage;
import com.googlecode.perfectable.webchat.ChatService;
import com.googlecode.perfectable.webchat.Message;
import com.googlecode.perfectable.webchat.StandardMessage;

public class LogCreatedMessage implements ClientMessage {
	private static final long serialVersionUID = -7190391907599278346L;
	
	@JsonCreator
	public static LogCreatedMessage construct(@JsonProperty("text") String text) {
		return new LogCreatedMessage(text);
	}

	private final String text;

	private LogCreatedMessage(String text) {
		this.text = text;
	}
	
	public void pushInto(ChatService chatService) {
		Message message = StandardMessage.of(this.text);
		chatService.receive(message);
	}
	
}
